package com.guigu.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guigu.pojo.GatherInfo;
import com.guigu.pojo.PurchaseDetailInfo;
import com.guigu.pojo.ReturnShopInfo;
import com.guigu.service.ReturnShopInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@CrossOrigin
@RestController
public class ReturnShopInfoController {

    @Autowired
    ReturnShopInfoService returnShopInfoService;

    //分页查询
    @GetMapping("queryAllReturn.action")
    public Page<ReturnShopInfo> queryAllReturn(ReturnShopInfo returnShopInfo,
                                               @RequestParam(value = "pageno",defaultValue = "1")Integer pageno,
                                               @RequestParam(value = "pagesize",defaultValue = "5")Integer pagesize
                                                ){
        return returnShopInfoService.queryAllreturn(returnShopInfo,pageno,pagesize);
    }

    //根据订单详情添加退货表
    @PostMapping("refund.action")
    public Map addRefundShopByDetailId(ReturnShopInfo refund,
                                       MultipartFile[] imgs,
                                       HttpServletRequest request){
        return returnShopInfoService.addRefundShopByDetailId(refund,imgs,request);
    }

    //根据订单详情id查询申请退货
    @GetMapping("refund.action/{id}")
    public ReturnShopInfo queryRefundByDetailId(@PathVariable Integer id){
        return returnShopInfoService.queryRefundByDetailId(id);
    }

    //审核退货申请
    @PutMapping("refund.action")
    public Map ckRefund(@RequestBody  ReturnShopInfo refund){
        return returnShopInfoService.ckRefund(refund);
    }

    //根据订单详情表id 修改数据
    @PutMapping("updatereturns.action")
    Map updatereturns(@RequestBody ReturnShopInfo returnShopInfo){

        return returnShopInfoService.updatereturns(returnShopInfo);
    }

    //签收退货单【确认是否送到总店】
    @PutMapping("receiptForReturn.action")
    public Map receiptForReturn (@RequestBody ReturnShopInfo refund){
        return returnShopInfoService.receiptForReturn(refund);
    }
}
